﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using System.Drawing;

namespace Havivi.Scrum.Board
{ 
  

    [ToolboxItemAttribute(false)]
    public class Board :   System.Web.UI.WebControls.WebParts.WebPart, IWebEditable
    {
        
        public   string SiteUrl
        {
            get
            {
                string _siteUrl = string.Empty;
                if (SPContext.Current !=null)
                {
                    if(SPContext.Current.Site!=null)
                    {
                        _siteUrl = SPContext.Current.Site.Url;
                    }
                }
                return _siteUrl;
            }
             
        }

        private bool _error = false;
        string listName = string.Empty;
        [WebBrowsable(false)]
        [Personalizable(PersonalizationScope.Shared)]
        public string ListName
        {
            get
            {
                if (listName == string.Empty)
                {
                    listName = Constants.SprintBacklog;
                }
                return listName;
            }
            set
            {
                listName = value;
            }
        }

        object IWebEditable.WebBrowsableObject { get { return this; } }

        private bool useHandwriting = false;
        [WebBrowsable(false)]
        [Personalizable(PersonalizationScope.Shared)]
        public bool UseHandwriting
        {
            get
            {

                return useHandwriting;
            }
            set
            {
                useHandwriting = value;
            }
        }

        private bool showPercentComplete = true;
        [WebBrowsable(false)]
        [Personalizable(PersonalizationScope.Shared)]
        public bool ShowPercentComplete
        {
            get
            {

                return showPercentComplete;
            }
            set
            {
                showPercentComplete = value;
            }
        }

        private bool showStatus = false;
        [WebBrowsable(false)]
        [Personalizable(PersonalizationScope.Shared)]
        public bool ShowStatus
        {
            get
            {
                return showStatus;
            }
            set
            {
                showStatus = value;
            }
        }

        private bool showAvatars = false;
        [WebBrowsable(false)]
        [Personalizable(PersonalizationScope.Shared)]
        public bool ShowAvatars
        {
            get
            {
                return showAvatars;
            }
            set
            {
                showAvatars = value;
            }
        }


        private bool showToolbar = true;
        [WebBrowsable(false)]
        [Personalizable(PersonalizationScope.Shared)]
        public bool ShowToolbar
        {
            get
            {
                return showToolbar;
            }
            set
            {
                showToolbar = value;
            }
        }

        public Board()
        {
            this.ExportMode = WebPartExportMode.All;
        }

        protected override void CreateChildControls()
        {
            if (!_error)
            {
                try
                {
                    base.CreateChildControls();
                    DrawBoard();
                }
                catch (Exception ex)
                {
                    HandleException(ex);
                }
            }
        }

        public void DrawBoard()
        {
            this.Controls.Clear();
            Table table = new Table();
            table.CellSpacing = 0;
            table.CellPadding = 0;
            table.BorderWidth = 1;
            table.BorderColor = Color.Gray;
            table.Width = Unit.Percentage(100);
            table.Height = Unit.Percentage(100);

            TableRow row1 = new TableRow();

            row1.Height = Unit.Pixel(40);
            TableRow row2 = new TableRow();
            row2.VerticalAlign = VerticalAlign.Top;
            string[] columns = GetColumns();
            bool firstColl = true;
            bool lastColl = false;
            int index = 1;

            foreach (string column in columns)
            {
                if (index == columns.Length)
                {
                    lastColl = true;
                }

                TableCell cell = new TableCell();
                cell.Style.Add("padding-top", "10px");
                cell.Style.Add("width", (100 / columns.Length).ToString() + "%");
                cell.HorizontalAlign = HorizontalAlign.Center;
                if (UseHandwriting)
                {
                    cell.Controls.Add(new LiteralControl("<font style='font-size: 28px;font-family: Bradley Hand ITC, ariel;'>" + column + "</font>"));
                }
                else
                {
                    cell.Controls.Add(new LiteralControl("<font style='font-size: 26px;font-family: ariel;'>" + column + "</font>"));
                }

                cell.Controls.Add(new LiteralControl("<hr style='height:1px;width:99%;color:gray'>"));
                cell.Height = Unit.Pixel(40);
                if (!lastColl)
                {
                    cell.Style.Add("border-right", "1px solid gray");
                }
                row1.Cells.Add(cell);



                SPListItemCollection itemTasks = GetTasks(index.ToString());
                cell = new TableCell();
                cell.Style.Add("padding-left", "10px");

                if (itemTasks != null)
                {
                    foreach (SPListItem item in itemTasks)
                    {
                        AddStroy(cell, firstColl, lastColl, item);
                    }
                    if (!lastColl)
                    {
                        cell.Style.Add("border-right", "1px solid gray");
                    }
                    row2.Cells.Add(cell);
                }

                firstColl = false;
                index++;
            }
            table.Rows.Add(row1);


            table.Rows.Add(row2);
            this.Controls.Add(table);
            if (ShowToolbar)
            {
                this.Controls.Add(new LiteralControl("<br/><br/>"));

                this.Controls.Add(new LiteralControl("Tasks: "));
                SPListItemCollection items = GetAllTasks("0");
                DropDownList ddl = new DropDownList();
                ddl.ID = "ddlScrumTaskBoard";
                ddl.Width = 300;
                bool buttnEnabled = false;
                foreach (SPListItem item in items)
                {
                    ddl.Items.Add(new ListItem(item.Title, item.ID.ToString()));
                    buttnEnabled = true;
                }
                this.Controls.Add(ddl);
                this.Controls.Add(new LiteralControl(" "));
                Button buttnAdd = new Button();
                buttnAdd.CssClass = "ms-ButtonHeightWidth";
                buttnAdd.Text = "Add to Board";
                buttnAdd.Click += new EventHandler(buttnAdd_Click);
                buttnAdd.Enabled = buttnEnabled;
                this.Controls.Add(buttnAdd);
                this.Controls.Add(new LiteralControl(" "));
                Button buttnClear = new Button();
                buttnClear.CssClass = "ms-ButtonHeightWidth";
                buttnClear.Text = "Clear Board";
                buttnClear.Click += new EventHandler(buttnClear_Click);
                this.Controls.Add(buttnClear);

                this.Controls.Add(new LiteralControl(Constants.signature));
            }
        }

        private void buttnClear_Click(object sender, EventArgs e)
        {
            using (SPSite site = new SPSite(SPContext.Current.Site.ID))
            {
                using (SPWeb web = site.OpenWeb(SPContext.Current.Web.ID))
                {
                    SPList list = web.Lists[ListName];
                    SPListItemCollection items = list.Items;
                    foreach (SPListItem item in items)
                    {
                        item[Constants.ScrumTaskBoardColumn] = "0";
                        item.Update();
                    }

                }
            }
            DrawBoard();
        }

        private void buttnAdd_Click(object sender, EventArgs e)
        {
            using (SPSite site = new SPSite(SPContext.Current.Site.ID))
            {
                using (SPWeb web = site.OpenWeb(SPContext.Current.Web.ID))
                {
                    SPList list = web.Lists[ListName];
                    DropDownList ddl = (DropDownList)this.FindControl("ddlScrumTaskBoard");
                    int id = int.Parse(ddl.SelectedValue);
                    SPListItem item = list.GetItemById(id);
                    item[Constants.ScrumTaskBoardColumn] = "1";
                    item[Constants.ScrumBoardWebpartID] = this.UniqueID;
                    item.Update();

                }
            }
            DrawBoard();
        }

        private SPListItemCollection GetTasks(string col)
        {
            using (SPSite site = new SPSite(SPContext.Current.Site.ID))
            {
                using (SPWeb web = site.OpenWeb(SPContext.Current.Web.ID))
                {
                    SPList list = web.Lists[ListName];
                    SPQuery qry = new SPQuery();
                    qry.Query = "<Where><And><Eq><FieldRef Name='" + Constants.ScrumTaskBoardColumn + "' /><Value Type='Text'>" + col + "</Value></Eq><Eq><FieldRef Name='" + Constants.ScrumBoardWebpartID + "' /><Value Type='Text'>" + this.UniqueID + "</Value></Eq></And></Where>";
                    qry.ViewFields = "<FieldRef Name='Title' /><FieldRef Name='ID' /><FieldRef Name='Status' /><FieldRef Name='PercentComplete' /><FieldRef Name='Priority' /><FieldRef Name='AssignedTo' /><FieldRef Name='Body' /><FieldRef Name='StartDate' /><FieldRef Name='DueDate' />";
                    return list.GetItems(qry);
                }
            }
        }

        private SPListItemCollection GetAllTasks(string col)
        {
            using (SPSite site = new SPSite(SPContext.Current.Site.ID))
            {
                using (SPWeb web = site.OpenWeb(SPContext.Current.Web.ID))
                {
                    SPList list = web.Lists[ListName];
                    SPQuery qry = new SPQuery();
                    qry.Query = "<Where><Eq><FieldRef Name='" + Constants.ScrumTaskBoardColumn + "' /><Value Type='Text'>" + col + "</Value></Eq></Where>";
                    qry.ViewFields = "<FieldRef Name='Title' /><FieldRef Name='ID' /><FieldRef Name='Status' /><FieldRef Name='PercentComplete' /><FieldRef Name='Priority' /><FieldRef Name='AssignedTo' /><FieldRef Name='Body' /><FieldRef Name='StartDate' /><FieldRef Name='DueDate' />";
                    return list.GetItems(qry);
                }
            }
        }

        private void AddStroy(TableCell cell, bool firstColl, bool lastColl, SPListItem item)
        {

            Table tableStory = CreateStory(firstColl, lastColl, item);
            cell.Controls.Add(new LiteralControl("<DIV>"));
            cell.Controls.Add(tableStory);
            cell.Controls.Add(new LiteralControl("</DIV>"));
        }

        private string[] GetColumns()
        {
            string[] columns = new string[0];
            using (SPSite site = new SPSite(SPContext.Current.Site.ID))
            {
                using (SPWeb web = site.OpenWeb(SPContext.Current.Web.ID))
                {
                    SPList list = web.Lists[Constants.SprintBacklog + " Columns"];
                    int itemCount = list.ItemCount;
                    if (itemCount > 0)
                    {
                        SPListItemCollection items = list.Items;
                        columns = new string[itemCount];
                        int index = 0;
                        foreach (SPListItem item in items)
                        {
                            columns[index] = item.Title;
                            index++;
                        }
                    }
                }
            }
            return columns;
        }

        private string GetPlainText(string body)
        {
            string plainText = body;
            try
            {
                Regex regex = new Regex("\\<[^\\>]*\\>");
                plainText = regex.Replace(plainText, String.Empty);
            }
            catch
            { }
            return plainText;
        }

        private Table CreateStory(bool firstColl, bool lastColl, SPListItem item)
        {
            Table table = new Table();
            table.Style.Add("float", "left");
            table.CellSpacing = 0;
            table.CellPadding = 0;
            table.Width = Unit.Pixel(135);
            table.Height = Unit.Pixel(165);
            string priority = "HS.Note_Normal.jpg";
            string assignedToID = string.Empty;
            string assignedToName = string.Empty;
            string assignedToImage = string.Empty;

            if (ShowAvatars)
            {
                if (item["AssignedTo"] != null)
                {
                    SPFieldUserValue userValue = new SPFieldUserValue(item.Web, item["AssignedTo"] as string);
                    assignedToID = userValue.User.ID.ToString();
                    assignedToName = userValue.User.Name;
                    assignedToImage = GetPictureUrl(assignedToID);
                }
            }

            if (item["Priority"] != null)
            {
                string prio = "(2)";
                try
                {
                    prio = item["Priority"].ToString().Substring(0, 3);
                }
                catch
                {
                    prio = "(2)";
                }
                switch (prio)
                {
                    case "(1)":
                        priority = "HS.Note_High.jpg";
                        break;
                    case "(3)":
                        priority = "HS.Note_Low.jpg";
                        break;
                    default:
                        priority = "HS.Note_Normal.jpg";
                        break;
                }
            }
            
            table.BackImageUrl =  SiteUrl + Constants.ImagesPath + priority;
            table.Style.Add("background-repeat", " no-repeat");
            TableRow row = new TableRow();
            row.Height = Unit.Pixel(145);
            TableCell cell = new TableCell();
            cell.Style.Add("cursor", "hand");
            //cell.Attributes.Add("onclick", "javascript:window.open('" + item.Web.Url + "/" + item.ParentList.Forms[PAGETYPE.PAGE_DISPLAYFORM].Url + "?ID=" + item.ID + "')");
            cell.VerticalAlign = VerticalAlign.Top;

            string body = string.Empty;
            if (item["Body"] != null)
            {
                body = GetPlainText(item["Body"].ToString());

            }
            if (UseHandwriting)
            {
                cell.Controls.Add(new LiteralControl("<div title='" + body + "' style='width:115px;font-size: 13px;font-family:Bradley Hand ITC, ariel;position:relative; margin-left: 10px; margin-top: 20px;'>"));
            }
            else
            {
                cell.Controls.Add(new LiteralControl("<div title='" + body + "' style='width:115px;font-size: 11px;font-family: ariel;position:relative; margin-left: 10px; margin-top: 20px;'>"));
            }

            int totalChar = 117;
            if (UseHandwriting)
            {
                totalChar = 97;
            }

            string title = item.Title;

            string percentComplete = "";
            if (ShowPercentComplete)
            {
                percentComplete = " [0%]";
                if (item["PercentComplete"] != null)
                {
                    percentComplete = " [" + item["PercentComplete"].ToString() + "%]";
                }
                title += percentComplete;

            }

            string status = "";
            if (ShowStatus)
            {
                if (item["Status"] != null)
                {
                    status = " [" + item["Status"].ToString() + "]";
                }
                title += status;
            }



            if (item.Title.Length > totalChar)
            {

                if (ShowPercentComplete)
                {
                    if (ShowStatus)
                    {
                        title = item.Title.Substring(0, totalChar) + "... " + percentComplete + " " + status;
                    }
                    else
                    {
                        title = item.Title.Substring(0, totalChar) + "... " + percentComplete;
                    }
                }
                else
                {
                    if (ShowStatus)
                    {
                        title = item.Title.Substring(0, totalChar) + "... " + status;
                    }
                    else
                    {
                        title = item.Title.Substring(0, totalChar) + "...";
                    }
                }
            }
            if (assignedToImage != string.Empty && ShowAvatars)
            {
                cell.Controls.Add(new LiteralControl("<img  style='float:left;margin:0 5px 0 0;width:50;height:50px;' alt='" + assignedToName + "' title='" + assignedToName + "' src='" + assignedToImage + "' />"));
            }
            cell.Controls.Add(new LiteralControl(title));
            cell.Controls.Add(new LiteralControl("</div>"));
            row.Cells.Add(cell);
            table.Rows.Add(row);
            row = new TableRow();
            row.Height = Unit.Pixel(20);

            cell = new TableCell();
            cell.VerticalAlign = VerticalAlign.Middle;
            cell.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;

            if (!firstColl)
            {
                ImageButton imgLeft = new ImageButton();
                imgLeft.ImageUrl = SiteUrl + Constants.ImagesPath + "HS.Left.png";
                imgLeft.ID = "ScrumTaskBoardImgLeft" + item.ID.ToString();
                imgLeft.Click += new ImageClickEventHandler(imgLeft_Click);
                imgLeft.ToolTip = "Move task back to previous column";
                cell.Controls.Add(imgLeft);
                cell.Controls.Add(new LiteralControl(" "));
            }

            ImageButton imgDelete = new ImageButton();
            imgDelete.ID = "ScrumTaskBoardImgDelete" + item.ID.ToString();
            imgDelete.Click += new ImageClickEventHandler(imgDelete_Click);
            imgDelete.ImageUrl = SiteUrl + Constants.ImagesPath + "HS.Delete.png";
            imgDelete.ToolTip = "Remove " + item.Title + " from ScrumTaskBoard";
            cell.Controls.Add(imgDelete);

            if (!lastColl)
            {
                cell.Controls.Add(new LiteralControl(" "));
                ImageButton imgRight = new ImageButton();
                imgRight.ID = "ScrumTaskBoardImgRight" + item.ID.ToString();
                imgRight.Click += new ImageClickEventHandler(imgRight_Click);
                imgRight.ImageUrl = SiteUrl + Constants.ImagesPath + "HS.Right.png";
                imgRight.ToolTip = "Move task to the next column";
                cell.Controls.Add(imgRight);
            }

            row.Cells.Add(cell);
            table.Rows.Add(row);
            return table;
        }

        private string GetPictureUrl(string id)
        {
            string pictureUrl = string.Empty;
            try
            {
                using (SPSite site = new SPSite(SPContext.Current.Site.ID))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        SPList list = web.SiteUserInfoList;
                        SPQuery qry = new SPQuery();
                        qry.Query = "<Where><Eq><FieldRef Name = 'ID'/><Value Type='Text'>" + id + "</Value></Eq></Where>";
                        qry.ViewFields = "<FieldRef Name='Picture' />";
                        SPListItemCollection itemCollection = list.GetItems(qry); ;
                        if (itemCollection.Count > 0)
                        {
                            SPListItem item = itemCollection[0];
                            SPField filed = list.Fields.GetFieldByInternalName("Picture");
                            if (item[filed.InternalName] != null)
                            {
                                SPFieldUrlValue urlValue = new SPFieldUrlValue(item[filed.InternalName] as string);
                                pictureUrl = urlValue.Url; ;
                            }
                        }
                    }
                }
            }
            catch
            {
                //error getting user picture - do nothing
            }

            return pictureUrl;

        }

        private void imgDelete_Click(object sender, ImageClickEventArgs e)
        {
            using (SPSite site = new SPSite(SPContext.Current.Site.ID))
            {
                using (SPWeb web = site.OpenWeb(SPContext.Current.Web.ID))
                {

                    ImageButton imgbtn = (ImageButton)sender;
                    int id = int.Parse(imgbtn.ID.Replace("ScrumTaskBoardImgDelete", ""));
                    SPList list = web.Lists[ListName];
                    SPListItem item = list.GetItemById(id);
                    item[Constants.ScrumTaskBoardColumn] = "0";
                    item.Update();

                }
            }
            DrawBoard();
        }

        private void imgLeft_Click(object sender, ImageClickEventArgs e)
        {
            using (SPSite site = new SPSite(SPContext.Current.Site.ID))
            {
                using (SPWeb web = site.OpenWeb(SPContext.Current.Web.ID))
                {

                    ImageButton imgbtn = (ImageButton)sender;
                    int id = int.Parse(imgbtn.ID.Replace("ScrumTaskBoardImgLeft", ""));
                    SPList list = web.Lists[ListName];
                    SPListItem item = list.GetItemById(id);
                    int ScrumTaskBoardColumn = int.Parse(item[Constants.ScrumTaskBoardColumn].ToString());
                    ScrumTaskBoardColumn--;
                    item[Constants.ScrumTaskBoardColumn] = ScrumTaskBoardColumn.ToString();
                    item.Update();

                }
            }
            DrawBoard();
        }

        private void imgRight_Click(object sender, ImageClickEventArgs e)
        {
            using (SPSite site = new SPSite(SPContext.Current.Site.ID))
            {
                using (SPWeb web = site.OpenWeb(SPContext.Current.Web.ID))
                {
                    ImageButton imgbtn = (ImageButton)sender;
                    int id = int.Parse(imgbtn.ID.Replace("ScrumTaskBoardImgRight", ""));
                    SPList list = web.Lists[ListName];
                    SPListItem item = list.GetItemById(id);
                    int ScrumTaskBoardColumn = int.Parse(item[Constants.ScrumTaskBoardColumn].ToString());
                    ScrumTaskBoardColumn++;
                    item[Constants.ScrumTaskBoardColumn] = ScrumTaskBoardColumn.ToString();
                    item.Update();
                }
            }
            DrawBoard();
        }

        private void HandleException(Exception ex)
        {
            this._error = true;
            this.Controls.Clear();
            this.Controls.Add(new LiteralControl(ex.Message));
        }

        EditorPartCollection IWebEditable.CreateEditorParts()
        {
            List<EditorPart> editors = new List<EditorPart>();
            editors.Insert(editors.Count, new ScrumTaskBoardToolPart(this.ID));
            return new EditorPartCollection(editors);
        }
    }

    public class ScrumTaskBoardToolPart : EditorPart
    {
        DropDownList listDropDownList = new DropDownList();
        CheckBox useHandwriting = new CheckBox();
        CheckBox showAvatars = new CheckBox();
        CheckBox showPercentComplete = new CheckBox();
        CheckBox showStatus = new CheckBox();
        CheckBox showToolbar = new CheckBox();

        public ScrumTaskBoardToolPart(string webPartID)
        {
            this.Title = "Scrum Task Board Properties";
            this.ID = "ScrumTaskBoardEditorPart" + webPartID;
        }

        public override bool ApplyChanges()
        {
            EnsureChildControls();
            Save();
            return true;
        }

        private void Save()
        {
            Board ScrumTaskBoard = WebPartToEdit as Board;
            ScrumTaskBoard.ListName = listDropDownList.SelectedValue;
            ScrumTaskBoard.UseHandwriting = useHandwriting.Checked;
            ScrumTaskBoard.ShowPercentComplete = showPercentComplete.Checked;
            ScrumTaskBoard.ShowStatus = showStatus.Checked;
            ScrumTaskBoard.ShowToolbar = showToolbar.Checked;
            ScrumTaskBoard.ShowAvatars = showAvatars.Checked;
            using (SPSite site = new SPSite(SPContext.Current.Site.ID))
            {

                using (SPWeb web = site.OpenWeb(SPContext.Current.Web.ID))
                {
                    SPList list = web.Lists[ScrumTaskBoard.ListName];
                    SPListItemCollection items = list.Items;
                    web.AllowUnsafeUpdates = true;

                    if (!list.Fields.ContainsField(Constants.ScrumTaskBoardColumn))
                    {
                        string id = list.Fields.Add(Constants.ScrumTaskBoardColumn, SPFieldType.Text, false);
                        SPField field = list.Fields[id];
                        field.DefaultValue = "0";
                        if (field.CanToggleHidden)
                        {
                            field.Hidden = true;
                        }
                        field.Update();
                    }


                    if (!list.Fields.ContainsField(Constants.ScrumBoardWebpartID))
                    {
                        string id = list.Fields.Add(Constants.ScrumBoardWebpartID, SPFieldType.Text, false);
                        SPField field = list.Fields[id];
                        if (field.CanToggleHidden)
                        {
                            field.Hidden = true;
                        }
                        field.Update();
                    }

                    list.Update();
                    web.Update();

                    foreach (SPListItem item in items)
                    {
                        if (item[Constants.ScrumTaskBoardColumn] == null)
                        {
                            item[Constants.ScrumTaskBoardColumn] = "0";
                            item.Update();
                        }
                        else if (item[Constants.ScrumTaskBoardColumn].ToString() == "")
                        {
                            item[Constants.ScrumTaskBoardColumn] = "0";
                            item.Update();
                        }
                    }

                }
            }
            ScrumTaskBoard.DrawBoard();
        }

        public override void SyncChanges()
        {
            EnsureChildControls();
            Board ScrumTaskBoard = WebPartToEdit as Board;
            listDropDownList.SelectedValue = ScrumTaskBoard.ListName;
            useHandwriting.Checked = ScrumTaskBoard.UseHandwriting;
            showPercentComplete.Checked = ScrumTaskBoard.ShowPercentComplete;
            showStatus.Checked = ScrumTaskBoard.ShowStatus;
            showToolbar.Checked = ScrumTaskBoard.ShowToolbar;
            showAvatars.Checked = ScrumTaskBoard.ShowAvatars;
            // Save();
        }

        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            Board ScrumTaskBoard = WebPartToEdit as Board;
            this.Controls.Add(new LiteralControl("<div style='margin-left: 10px;' ><br />In order to use ScrumTaskBoard Webpart you must associate it with a Task list:<br /><br />"));
            listDropDownList = new DropDownList();
            listDropDownList.Items.Clear();
            using (SPSite site = new SPSite(SPContext.Current.Site.ID))
            {

                using (SPWeb web = site.OpenWeb(SPContext.Current.Web.ID))
                {
                    foreach (SPList list in web.Lists)
                    {
                        if (list.BaseTemplate == SPListTemplateType.Tasks)
                        {
                            listDropDownList.Items.Add(list.Title);
                        }
                    }

                }
            }
            listDropDownList.SelectedValue = ScrumTaskBoard.ListName;
            useHandwriting.Checked = ScrumTaskBoard.UseHandwriting;
            showPercentComplete.Checked = ScrumTaskBoard.ShowPercentComplete;
            showStatus.Checked = ScrumTaskBoard.ShowStatus;
            showToolbar.Checked = ScrumTaskBoard.ShowToolbar;
            showAvatars.Checked = ScrumTaskBoard.ShowAvatars;
            useHandwriting.Text = "Use handwriting fonts";
            showPercentComplete.Text = "Show percent complete";
            showStatus.Text = "Show status";
            showAvatars.Text = "Show avatars";
            showToolbar.Text = "Show toolbar";
            this.Controls.Add(listDropDownList);
            this.Controls.Add(new LiteralControl("<br /><br />"));
            this.Controls.Add(showAvatars);
            this.Controls.Add(showToolbar);
            this.Controls.Add(new LiteralControl("<br />"));
            this.Controls.Add(useHandwriting);
            this.Controls.Add(new LiteralControl("<br />"));
            this.Controls.Add(showPercentComplete);
            this.Controls.Add(new LiteralControl("<br />"));
            this.Controls.Add(showStatus);
            this.Controls.Add(new LiteralControl("<br />"));
            this.Controls.Add(showToolbar);
            this.Controls.Add(new LiteralControl("</div><br /><DIV style=\"WIDTH: 100%;padding-right:10px;\" class=UserDottedLine></DIV><br> <div style=\"margin-left: 10px;margin-right: 30px; \">"));
            this.Controls.Add(new LiteralControl("<a rel=\"license\" href=\"http://creativecommons.org/licenses/by/3.0/\"><img alt=\"Creative Commons License\" style=\"border-width:0\" src=\"http://i.creativecommons.org/l/by-nc-nd/3.0/88x31.png\" /></a><br /><span xmlns:dct=\"http://purl.org/dc/terms/\" href=\"http://purl.org/dc/dcmitype/InteractiveResource\" property=\"dct:title\" rel=\"dct:type\">ScrumTaskBoard</span> by <a xmlns:cc=\"http://creativecommons.org/ns#\" href=\"http://havivi.blogspot.com\" property=\"cc:attributionName\" rel=\"cc:attributionURL\">Alon Havivi</a> is licensed under a <a rel=\"license\" href=\"http://creativecommons.org/licenses/by/3.0/\">Creative Commons Attribution 3.0 Unported License</a>.<br />Based on a work at <a xmlns:dct=\"http://purl.org/dc/terms/\" href=\"http://ScrumTaskBoard.codeplex.com\" rel=\"dct:source\">ScrumTaskBoard.codeplex.com</a>.<br />Permissions beyond the scope of this license may be available at <a xmlns:cc=\"http://creativecommons.org/ns#\" href=\"http://ScrumTaskBoard.codeplex.com/license\" rel=\"cc:morePermissions\">http://ScrumTaskBoard.codeplex.com/license</a><br /><br /></div><DIV style=\"WIDTH: 100%\" class=UserDottedLine></DIV>"));
        }
    }
}
